home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Number Styles.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  1.9 KB  |  78 lines  |  [TEXT/KAHL]

  1. /****************************************************************************************************
  2.     6/96 bob    Updated #includes to support changed GX Library names.
  3.     
  4.     ©1990 - 1996  Apple Computer, Inc.
  5.     All rights reserved.
  6. ****************************************************************************************************/
  7. #include <Types.h>
  8. #include <QuickDraw.h>
  9. #include <Fonts.h>
  10. #include <Windows.h>
  11. #include <Menus.h>
  12. #include <SegLoad.h>
  13. #include <Memory.h>
  14. #include <Desk.h>
  15.  
  16. #include <GXGraphics.h>
  17. #include "GraphicsLibraries.h"
  18. #include <GXEnvironment.h>
  19.  
  20. #include <GXTypes.h>
  21. #include <GXLayout.h>
  22. #include "LayoutLibrary.h"
  23. #include "LayoutFeatureConstants.h"
  24.  
  25. #include "SampleInterface.h"
  26.  
  27. short MyStrLen(char *x);
  28. static short MyStrLen(x)
  29. char    *x;
  30.     {
  31.     short c = 0;
  32.     while (*x++) c++;
  33.     return c;
  34.     }    /* MyStrLen */
  35.  
  36. void NumberStyles(WindowPtr sampleWindow)
  37.     {
  38.     /* Variables */
  39.     char        *myString = "Digits: 0123456789";
  40.     gxPoint        myPoint;
  41.     gxRunFeature    gxRunFeature;
  42.     gxShape        layout;
  43.     short        len, level = 0;
  44.     gxStyle        myStyle;
  45.     gxViewPort    aViewPort;
  46.     
  47.     /* Initialization */
  48.     
  49.     myPoint.x = ff(20);
  50.     myPoint.y = ff(80);
  51.     
  52.     aViewPort = GXNewWindowViewPort(sampleWindow);
  53.     SetDefaultViewPort(aViewPort);
  54.     
  55.     len = MyStrLen(myString);
  56.     
  57.     myStyle = NewLayoutStyle((char *) "\pHoefler Text Italic", ff(50), 0, nil, nil, 0, nil);
  58.     gxRunFeature.featureType = numberSpacingType;
  59.     gxRunFeature.featureSelector = monospacedNumbersSelector;
  60.     GXSetStyleRunFeatures(myStyle, 1, &gxRunFeature);
  61.     
  62.     layout = GXNewLayout(
  63.         1, &len, (void *) &myString,
  64.         1, &len, &myStyle,
  65.         1, &len, &level,
  66.         nil, &myPoint);
  67.     GXDrawShape(layout);
  68.     
  69.     gxRunFeature.featureSelector = proportionalNumbersSelector;
  70.     GXSetStyleRunFeatures(myStyle, 1, &gxRunFeature);
  71.     GXMoveShape(layout, 0, ff(75));
  72.     GXDrawShape(layout);
  73.     
  74.     GXDisposeShape(layout);
  75.     GXDisposeStyle(myStyle);
  76.     GXDisposeViewPort(aViewPort);
  77.     }    /* main */
  78.